package cn.dengta.webapp.im.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.BaseEntity;
import cn.dengta.webapp.user.cache.UserSummary;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 搭讪推荐统计数据
 *
 * @author lgy
 * @since 2022-11-08
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("im_greet_recommend_statistics")
public class GreetRecommendStatistics extends BaseEntity {

	/** 搭讪数 */
	Integer times;
	/** 搭讪用户人数 */
	Integer totalCount;
	/** 被搭讪用户数（VIP） */
	Integer vipCount;
	/** 被搭讪用户数（钻石） */
	Integer coinCount;
	/** 统计日期 */
	Date reportTime;

	public GreetRecommendStatistics init() {
		times = totalCount = vipCount = coinCount = 0;
		return this;
	}

	public void addCount(UserSummary summary) {
		if (summary != null) {
			int count = summary.acceptCoinOnly() ? (coinCount += 1) : (vipCount += 1);
			totalCount += 1;
		}
	}

	public static final String TIMES = "times";
	public static final String TOTAL_COUNT = "total_count";
	public static final String VIP_COUNT = "vip_count";
	public static final String COIN_COUNT = "coin_count";
	public static final String REPORT_TIME = "report_time";

}
